import 'package:getx_scaffold/getx_scaffold.dart';
import 'package:oramemo/common/langs/index.dart';

class UrlUtil {

  /// 打开链接
  static Future<void> launchWebURL(String url) async {
    final Uri uri = Uri.parse(url);
    if (await canLaunchUrl(uri)) {
      await launchUrl(uri);
    } else {
      Toast.show(TextKey.openLinkFailed.tr);
    }
  }

  /// 调起拨号页
  static Future<void> launchTelURL(String phone) async {
    final Uri uri = Uri.parse('tel:$phone');
    if (await canLaunchUrl(uri)) {
      await launchUrl(uri);
    } else {
      Toast.show(TextKey.dialFailed.tr);
    }
  }
}